# 获取当前工程路径

import os


def pro_path(filename):
    # filename = 'three_robot'
    dirpath = os.path.abspath('.')
    # print(dirpath)
    path = dirpath[:dirpath.find(filename)] + filename
    return path


# 读取指定文件内容

def get_body(body_path):
    with open(pro_path('three_robot') + f'{body_path}', encoding="utf-8") as f:
        body = f.read()
        return body


def print_exception(func):
    def wrapper(*args, **kwargs):
        '''
        异常捕捉装饰器
        :param func:
        :return:
        '''
        try:
            res = func(*args, **kwargs)
            return res
        except Exception as e:
            print(f'{func} : {e}')
            # sys.exit(1)
        # return res
    return wrapper
